package Utils;

import BasicDataStructures.SingleListNode;

public class ListUtils {
    public static SingleListNode generateList(int[] val) {
        if(val == null || val.length < 1) return null;
        SingleListNode head = new SingleListNode();
        SingleListNode curNode = head;
        int cur = 0;
        while(cur < val.length) {
            curNode.data = val[cur++];
            if(cur == val.length) break;
            curNode.next = new SingleListNode();
            curNode = curNode.next;
        }
        return head;
    }

    public static void printList(SingleListNode head) {
        while(head != null) {
            System.out.print(head.data + "->");
            head = head.next;
        }
        System.out.println("END");
    }
}
